<?php

namespace app\common\logic;

use app\common\model\Tag;
use app\common\resourceHandle\ShopResource;
use think\db\Query;

class TagLogic extends BaseLogic
{
    public $model;

    public $resourceHandle;

    public function assignModel()
    {
        $this->model          = new Tag();
        $this->resourceHandle = new ShopResource();
    }

    /**
     * 搜索条件处理
     * @param Query $query
     * @param array $params
     * @return Query
     */
    public function handleSearch(Query $query, array $params): Query
    {
        if (isset($params['status']) && $params['status'] !== '') {
            $query->where('status', $params['status']);
        }
        return $query;
    }

    /**
     * 标签列表
     * @param array $params
     * @return array
     * @throws \think\exception\DbException
     */
    public function list(array $params): array
    {
        $params['status']    = $this->enable;
        $params['orderBy']   = 'sort';
        $params['orderType'] = 'desc';
        return $this->getList($params)->toArray();
    }

}